<include file="Public/head" />
<script src="__PUBLIC__/layer/layer.js"></script>
<body>
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> {:L("canzhuoliebiao")}</strong></div>
    <div class="padding border-bottom">

      <ul class="search" style="padding-left:10px;">
        <li> <a class="button border-main icon-plus-square-o" href="{:U('table/addTable')}"> {:L("tianjia")}</a> </li>
        <li>{:L("sousuo")}：</li>
        <li>
          <form action="{:U('table/index')}" method="get">
          <input type="text" placeholder="{:L('qingshuru')}{:L('canzhuoleixing')}" name="table_cate_name" value="{$table_cate_name}" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <input type="submit" value="{:L('sousuo')}" class="button border-main icon-search"/>
          </form>
        </li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th width="10%">{:L("canzhuohao")}</th>
        <th width="20%">{:L("canzhuoleixing")}</th>
        <th width="20%">{:L("canzhuozhuangtai")}</th>
        <th width="10%">{:L("caozuo")}</th>
      </tr>
      <foreach name="info" item="v">
        <tr class="o{$v['id']}">
          <td>{$v['table_num']}</td>
          <td>{$v['table_cate_name']}</td>
          <td>
            <span class="sp01" onclick="is_show({$v['id']},this)">
            <if condition="$v['table_status'] eq 0">
              <img src="__PUBLIC__/web/images/no.png" width="18px;" >
              <else />
              <img src="__PUBLIC__/web/images/yes.png" width="18px;" >
            </if>
            </span>
          </td>
          <td>
<!--             <div class="button-group">
              <a class="button border-main" href="javascript:void(0)" onclick="showHTML({$v['table_num']})"><span class="icon-edit"></span> {:L("shengchengerweima")}
              </a>
            </div> -->
              <div class="button-group ">
                <a class="button border-main" href="javascript:void(0)" onclick="return del({$v['id']})"><span class="icon-edit"></span> {:L("shanchu")}</a>
              </div>
          </td>
        </tr>
      </foreach>
      <tr>
        <td colspan="10">
          <div class="pagelist">{$show}</div>
        </td>
      </tr>
    </table>
  </div>

  <script type="text/javascript">
    function del(id){
      if(confirm("{:L('shanchuxiaoxi')}")){
        var url = "{:U('Table/delete')}";
        $.getJSON(url,{id:id},function (data){
          if(data.result == 'tp1'){$('.o'+id).remove();}
          else if(data.result == 'break'){alert('ERROR.');}
        })
      }
    }
    function is_show(id,t){
      var url = "{:U('Table/is_show')}";
      $.getJSON(url,{id:id},function (data){
        if(data.result == 'yes'){
          $(t).find('img').attr('src',"__PUBLIC__/web/images/yes.png");
        }else if(data.result == 'no'){
          $(t).find('img').attr('src',"__PUBLIC__/web/images/no.png");
        }
      })
    }
       function showHTML(table_num){
         console.log(table_num);
         layer.open({
           type: 2,
           title: false,
           closeBtn: 1, //不显示关闭按钮
           shade: [0],
           area: ['300px', '300px'],
           offset: 'center', //右下角弹出
          // time: 2000, //2秒后自动关闭
           anim: 3,
           content:["{:U('Table/qrcode')}?id="+table_num, 'no'], //iframe的url，no代表不显示滚动条
         });
       }
  </script>
</body>
</html>